package com.hpeu_01.day0122;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class ImgSocketServer {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(9999);
        Socket accept = ss.accept();
        OutputStream os = new FileOutputStream("D:\\project\\JAVA\\java\\JavaSE\\src\\com\\hpeu_01\\day0122\\img.jpg");
        InputStream is = accept.getInputStream();
        byte[] b = new byte[1024];
        int len = -1;
        while ((len = is.read(b)) != -1){
            os.write(b,0,len);
        }
        is.close();
        os.close();
        accept.close();
        ss.close();
    }
}
